home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d18 / tpasmath.arc / MATH.PAS < prev    next >
Pascal/Delphi Source File  |  1991-04-28  |  2KB  |  56 lines

  1. (* Turbo Pascal 5.0 Math Functions *)
  2. unit MATH;
  3. {$IFDEF VER40} {$N+} {$ELSE} {$N+,E+} {$ENDIF}
  4.  
  5. interface
  6. Function Power( base, exponent : Real ) : Real; {power of base raised
  7.                                                   to exponent}
  8. Function Log( argument : Real ) : Real;  { log (base10) of argument}
  9. Function Rad( degrees : Real ) : Real;    {convert radians to degrees}
  10. Function Deg( radians : Real ) : Real;    {convert degrees to radians}
  11. Function Fact( x : Integer) : Double;   {factorial of x}
  12. Function Perm( n, r : Integer) : Double; {permutations of n taken r at
  13.                                          a time}
  14. Function Comb( n, r : Integer) : Double; {combinations of n taken r at
  15.                                          a time}
  16.  
  17.  
  18. implementation
  19. Function Power( base, exponent : Real) : Real;
  20.          begin
  21.               Power := EXP( exponent * LN( base))
  22.          end; {Power}
  23. Function Log( argument : Real) : Real;
  24.          const BASE = 10;
  25.          begin
  26.               Log := Ln( argument ) / Ln( BASE )
  27.          end; {Log}
  28. Function Rad( degrees : Real) : Real;
  29.          const DEGCONVERT = 180.0;
  30.          begin
  31.               Rad := Degrees * Pi / DEGCONVERT
  32.          end; {Rad}
  33. Function Deg( Radians : Real) : Real;
  34.          const RADCONVERT = 180.0;
  35.          begin
  36.               Deg := Radians * RADCONVERT / Pi
  37.          end; {Deg}
  38. Function Fact( x : Integer ) : Double;
  39.          var loop : Integer; mult : Double;
  40.              begin
  41.                   mult := 1;
  42.                   For loop :=1 To x Do
  43.                       mult := mult * loop;
  44.                   Fact := mult
  45.              end; {Fact}
  46. Function Perm( n, r : Integer ) : Double;
  47.          begin
  48.               Perm := Fact( n ) / Fact( n - r )
  49.          end; {Perm}
  50. Function Comb( n, r : Integer ) : Double;
  51.          begin
  52.               Comb := Perm( n, r ) / Fact( r )
  53.          end; {Comb}
  54. end. {Math unit}
  55.  
  56.